package com.ruoyi.personal.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.personal.domain.CriminalResponsibility;
import com.ruoyi.personal.service.ICriminalResponsibilityService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 刑事责任，用于记录刑事责任的相关信息Controller
 * 
 * @author qjp
 * @date 2024-09-18
 */
@RestController
@RequestMapping("/responsibility")
public class CriminalResponsibilityController extends BaseController
{
    @Autowired
    private ICriminalResponsibilityService criminalResponsibilityService;

    /**
     * 查询刑事责任，用于记录刑事责任的相关信息列表
     */
    @RequiresPermissions("personal:responsibility:list")
    @GetMapping("/list")
    public TableDataInfo list(CriminalResponsibility criminalResponsibility)
    {
        startPage();
        List<CriminalResponsibility> list = criminalResponsibilityService.selectCriminalResponsibilityList(criminalResponsibility);
        return getDataTable(list);
    }

    /**
     * 导出刑事责任，用于记录刑事责任的相关信息列表
     */
    @RequiresPermissions("personal:responsibility:export")
    @Log(title = "刑事责任，用于记录刑事责任的相关信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CriminalResponsibility criminalResponsibility)
    {
        List<CriminalResponsibility> list = criminalResponsibilityService.selectCriminalResponsibilityList(criminalResponsibility);
        ExcelUtil<CriminalResponsibility> util = new ExcelUtil<CriminalResponsibility>(CriminalResponsibility.class);
        util.exportExcel(response, list, "刑事责任，用于记录刑事责任的相关信息数据");
    }

    /**
     * 获取刑事责任，用于记录刑事责任的相关信息详细信息
     */
    @RequiresPermissions("personal:responsibility:query")
    @GetMapping(value = "/{Id}")
    public AjaxResult getInfo(@PathVariable("Id") Long Id)
    {
        return success(criminalResponsibilityService.selectCriminalResponsibilityById(Id));
    }

    /**
     * 新增刑事责任，用于记录刑事责任的相关信息
     */
    @RequiresPermissions("personal:responsibility:add")
    @Log(title = "刑事责任，用于记录刑事责任的相关信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CriminalResponsibility criminalResponsibility)
    {
        return toAjax(criminalResponsibilityService.insertCriminalResponsibility(criminalResponsibility));
    }

    /**
     * 修改刑事责任，用于记录刑事责任的相关信息
     */
    @RequiresPermissions("personal:responsibility:edit")
    @Log(title = "刑事责任，用于记录刑事责任的相关信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CriminalResponsibility criminalResponsibility)
    {
        return toAjax(criminalResponsibilityService.updateCriminalResponsibility(criminalResponsibility));
    }

    /**
     * 删除刑事责任，用于记录刑事责任的相关信息
     */
    @RequiresPermissions("personal:responsibility:remove")
    @Log(title = "刑事责任，用于记录刑事责任的相关信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{Ids}")
    public AjaxResult remove(@PathVariable Long[] Ids)
    {
        return toAjax(criminalResponsibilityService.deleteCriminalResponsibilityByIds(Ids));
    }
}
